using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class StartFatterBtn : MonoBehaviour
{ 
    private MBattleController mBattleController;
    MBattleController MBattleController
    {
        get
        {
            if(mBattleController == null)
            {
                var mainUI = GetComponentInParent<MBattleMainUI>();
                if (mainUI)
                {
                    mBattleController = mainUI.MBattleController;
                }
            }

            return mBattleController;
        }
    }
    // Start is called before the first frame update
    void Start()
    {
        
    }

    public void OnClick()
    {
        if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.OSXEditor)
        {
            DoFatter();
        }
        else
        {
            AudioController.instance.PauseMusic();

            Game.Instance.adManager.PlayVideoAd(() =>
                {
                    AudioController.instance.ResumeMusic();
                    DoFatter();
                }
                , () =>
                {
                    AudioController.instance.ResumeMusic();
                }, (err) =>
                {
                    AudioController.instance.ResumeMusic();
                    Game.Instance.ShowNoticePanel(err);
                });
        }
    }

    void DoFatter()
    {
        //MBattleController.me.bubbleGrowSpeed = MLocalUserData.GetAddBlowSpeedWithLv(7);
        //gameObject.SetActive(false);

        //var pref = GameResourceManager.Load<GameObject>(GameResourceManager.upgradeFxPath);
        //if (pref)
        //{
        //    var fx = Instantiate(pref);
        //    Destroy(fx, 3);
        //    fx.transform.position = MBattleController.me.transform.position;
        //}
    }
    
    // Update is called once per frame
    void Update()
    {
        
    }
}
